package com.formatos;

import java.io.File;
import java.io.IOException;

import javax.servlet.http.HttpServletResponse;

import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExporter;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.export.JRTextExporter;
import net.sf.jasperreports.engine.export.JRTextExporterParameter;

public class TXTReport implements Formato {

	public File escribirReporte(JasperPrint jasperPrint, HttpServletResponse response) throws JRException, IOException {
		
		response.setContentType("text/plain");
		JRExporter jRExporter = new JRTextExporter();
		jRExporter.setParameter(JRTextExporterParameter.CHARACTER_HEIGHT, Integer.valueOf("15"));
//		jRExporter.setParameter(JRTextExporterParameter.CHARACTER_WIDTH, Integer.valueOf("1"));
//		jRExporter.setParameter(JRTextExporterParameter.LINE_SEPARATOR," ");
		jRExporter.setParameter(JRTextExporterParameter.PAGE_WIDTH, Integer.valueOf("80"));
		jRExporter.setParameter(JRTextExporterParameter.PAGE_HEIGHT,Integer.valueOf("150"));
		jRExporter.setParameter(JRTextExporterParameter.JASPER_PRINT, jasperPrint);
//		OutputStream output = response.getOutputStream();
//		exporter.setParameter(JRTextExporterParameter.OUTPUT_STREAM, output);
//		jRExporter.exportReport();
//		output.close();
		return Util.export(jRExporter, "txt");
	}
	
	public Object clone() throws CloneNotSupportedException {
		return new TXTReport();
	}
}
